class QueryEntity {
    constructor({
                    serialNumber = '',
                    idcId = '',
                    houseId = '',
                    startTime = '',
                    endTime = '',
                    serialNumberAction = SearchActionConstant.ACCURATE,
                    idcIdAction = SearchActionConstant.ACCURATE,
                } = {}) {
        this.serialNumber = serialNumber;
        this.idcId = idcId;
        this.houseId = houseId;
        this.startTime = startTime;
        this.endTime = endTime;
        this.serialNumberAction = serialNumberAction;
        this.idcIdAction = idcIdAction;
    }
}

new BasicTableVue({
    data: function () {
        return {
            api: insFileApi,
            columns: [
                new TableColumn({
                    type: 'selection',
                    width: 30,
                    align: 'center',
                }),
                new TableColumn({
                    prop: 'serialNumber',
                    title: '指令文件序号',
                }),
                new TableColumn({
                    prop: 'insType',
                    title: '指令类型',
                    formatter: this.insTypeFormat,
                }),
                new TableColumn({
                    prop: 'idcId',
                    title: '经营者ID',
                }),
                new TableColumn({
                    prop: 'houseNameArr',
                    title: '机房范围',
                    sortable: false,
                }),
                new TableColumn({
                    prop: 'reportStatus',
                    title: '报备阶段',
                    formatter: TableColumn.reportStatusFormat,
                }),
                new TableColumn({
                    prop: 'createTime',
                    title: '生成时间',
                    formatter: TableColumn.datetimeFormat,
                }),
                new TableColumn({
                    prop: 'operating',
                    title: '操作',
                }),
            ],
            houses: [],
        }
    },
    methods: {
        createForm() {
            return new QueryEntity();
        },
        insTypeFormat(row, column, value, _index) {
            var result = '';
            value = parseInt(value);
            switch (value) {
                case 1:
                    result = '基础数据查询指令';
                    break;
                case 2:
                    result = '违法信息安全管理指令';
                    break;
                case 3:
                    result = '代码表发布指令';
                    break;
                case 4:
                    result = '基础数据核验处理指令';
                    break;
                case 5:
                    result = '免过滤网站列表指令';
                    break;
                case 6:
                    result = '违法网站列表指令';
                    break;
                case 7:
                    result = '活跃资源访问量查询指令';
                    break;
                case 8:
                    result = '违法管理指令执行记录指令';
                    break;
            }
            return result;
        },
        async initHouses() {
            this.houses = await baseHouseInfoApi.selectList();
        },
        init() {
            this.initHouses();
        },
    },
    watch: {
        'form.timeArray': function (newVal, oldVal) {
            if (newVal) {
                this.form.startTime = newVal[0];
                this.form.endTime = newVal[1];
            } else {
                this.form.startTime = '';
                this.form.endTime = '';
            }

        },
    },
})
